import React from 'react'
import {Button, InputNumber, Modal} from "antd";
import UserModel from "../../../model/user";
import Info from "../../../service/info";

class AddSuperVipModal extends React.Component {

    constructor(props) {
        super(props)
        this.model = new UserModel()
        this.state = {
            addVipInt: 0,
        }
    }

    onAddVipInputChange = (value) => {
        this.setState({
            addVipInt: value,
        })
    }

    addVip = () => {

        const user = this.props.user
        console.log(user)
        const params = {
            Uid: user.Id,
            Day: this.state.addVipInt,
        }
        this.model
            .addSuperVip(params)
            .then((resp) => {
                const ok = resp.data.ok
                if (ok === 1) {
                    Info.success('修改成功')
                    // this.modalCancel('addVip')
                    this.props.fetchAll()
                }
            })

    }

    render() {
        const addVipModal = <Modal
            title="添加超级VIP"
            visible={this.props.visible}
            style={{width: '100%',}}
            footer={null}
            maskClosable={true}
            onCancel={this.props.onCancel}
        >
            <InputNumber
                style={{marginRight: '8px',}}
                placeholder='天数'
                value={this.state.addVipInt}
                onChange={e => this.onAddVipInputChange(e)}
            />
            <Button
                onClick={this.addVip}
            >保存</Button>
        </Modal>
        return addVipModal
    }
}

export default AddSuperVipModal